const areaConfig = function (type, num) {
  var colors = ['#52DB75', '#FCBC05', '#FF8719', '#E25F5F', '#7A65DB', '#A33C6B']
  var texts = ['优', '良', '轻度', '重度', '严重']
  var range = {}
  switch (type) {
    case 'SO2':
      if (num <= 150) {
        range.text = texts[0]
        range.color = colors[0]
      } else if (num <= 500) {
        range.text = texts[1]
        range.color = colors[1]
      } else if (num <= 650) {
        range.text = texts[2]
        range.color = colors[2]
      } else if (num <= 800) {
        range.text = texts[3]
        range.color = colors[3]
      } else if (num <= 1600) {
        range.text = texts[4]
        range.color = colors[4]
      } else {
        range.text = texts[5]
        range.color = colors[5]
      }
      break
    case 'NO2':
      if (num <= 100) {
        range.text = texts[0]
        range.color = colors[0]
      } else if (num <= 200) {
        range.text = texts[1]
        range.color = colors[1]
      } else if (num <= 700) {
        range.text = texts[2]
        range.color = colors[2]
      } else if (num <= 1200) {
        range.text = texts[3]
        range.color = colors[3]
      } else if (num <= 2340) {
        range.text = texts[4]
        range.color = colors[4]
      } else {
        range.text = texts[5]
        range.color = colors[5]
      }
      break
    case 'PM10':
      if (num <= 50) {
        range.text = texts[0]
        range.color = colors[0]
      } else if (num <= 150) {
        range.text = texts[1]
        range.color = colors[1]
      } else if (num <= 250) {
        range.text = texts[2]
        range.color = colors[2]
      } else if (num <= 350) {
        range.text = texts[3]
        range.color = colors[3]
      } else if (num <= 420) {
        range.text = texts[4]
        range.color = colors[4]
      } else {
        range.text = texts[5]
        range.color = colors[5]
      }
      break
    case 'TSP':
      if (num <= 50) {
        range.text = texts[0]
        range.color = colors[0]
      } else if (num <= 150) {
        range.text = texts[1]
        range.color = colors[1]
      } else if (num <= 250) {
        range.text = texts[2]
        range.color = colors[2]
      } else if (num <= 350) {
        range.text = texts[3]
        range.color = colors[3]
      } else if (num <= 420) {
        range.text = texts[4]
        range.color = colors[4]
      } else {
        range.text = texts[5]
        range.color = colors[5]
      }
      break
    case 'CO':
      if (num <= 5) {
        range.text = texts[0]
        range.color = colors[0]
      } else if (num <= 10) {
        range.text = texts[1]
        range.color = colors[1]
      } else if (num <= 35) {
        range.text = texts[2]
        range.color = colors[2]
      } else if (num <= 60) {
        range.text = texts[3]
        range.color = colors[3]
      } else if (num <= 90) {
        range.text = texts[4]
        range.color = colors[4]
      } else {
        range.text = texts[5]
        range.color = colors[5]
      }
      break
    case 'O3':
      if (num <= 160) {
        range.text = texts[0]
        range.color = colors[0]
      } else if (num <= 200) {
        range.text = texts[1]
        range.color = colors[1]
      } else if (num <= 300) {
        range.text = texts[2]
        range.color = colors[2]
      } else if (num <= 400) {
        range.text = texts[3]
        range.color = colors[3]
      } else if (num <= 800) {
        range.text = texts[4]
        range.color = colors[4]
      } else {
        range.text = texts[4]
        range.color = colors[5]
      }
      break
    case 'PM2.5':
      if (num <= 35) {
        range.text = texts[0]
        range.color = colors[0]
      } else if (num <= 75) {
        range.text = texts[1]
        range.color = colors[1]
      } else if (num <= 115) {
        range.text = texts[2]
        range.color = colors[2]
      } else if (num <= 150) {
        range.text = texts[3]
        range.color = colors[3]
      } else if (num <= 250) {
        range.text = texts[4]
        range.color = colors[4]
      } else {
        range.text = texts[5]
        range.color = colors[5]
      }
      break
    case 'PM1':
      if (num <= 35) {
        range.text = texts[0]
        range.color = colors[0]
      } else if (num <= 75) {
        range.text = texts[1]
        range.color = colors[1]
      } else if (num <= 115) {
        range.text = texts[2]
        range.color = colors[2]
      } else if (num <= 150) {
        range.text = texts[3]
        range.color = colors[3]
      } else if (num <= 250) {
        range.text = texts[4]
        range.color = colors[4]
      } else {
        range.text = texts[5]
        range.color = colors[5]
      }
      break
    case 'AQI':
      if (num <= 50) {
        range.text = texts[0]
        range.color = colors[0]
      } else if (num <= 100) {
        range.text = texts[1]
        range.color = colors[1]
      } else if (num <= 150) {
        range.text = texts[2]
        range.color = colors[2]
      } else if (num <= 200) {
        range.text = texts[3]
        range.color = colors[3]
      } else if (num <= 300) {
        range.text = texts[4]
        range.color = colors[4]
      } else {
        range.text = texts[5]
        range.color = colors[5]
      }
      break
    default:
      break
  }
  return range
}

export default areaConfig

